﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Model.Catalog;
using System.Collections.Generic;

public partial class Style_FrontEnd_FrontEnd : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Show all category
        GetAllCategories();

    }

    //Method Show All Category
    void GetAllCategories()
    {
        ListView_Category.DataSource = Category.GetAllCategories();
        ListView_Category.DataBind();
    }

    //Get all quantity in Cart
    public int GetAllQuantityInCart()
    {
        int total = 0;
        if (Session["cart"] != null)
        {
            foreach (KeyValuePair<string, int> kvp in ((Dictionary<string, int>)Session["cart"]))
            {
                total += kvp.Value;
            }
            return total;

        }
        return 0;
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (Membership.ValidateUser(txtUsername.Value,txtPassword.Value))
        {
            FormsAuthentication.RedirectFromLoginPage(txtUsername.Value, cbxRemember.Checked);
 
        }
        else
        {
            lbMessage.Text = "UserName or Password is not correct!";
        }
    }
}
